﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Domain.MainModule.Entities;
using Infraestructure.Data.MainModule.UnitOfWork;
using Infraestructure.CrossCutting.Logging;
using Domain.MainModule.Addresses;
using Domain.MainModule.AddressTypes;
using Infraestructure.Data.MainModule.Repositories;

namespace Infraestructure.Data.MainModule.Tests.RepositoriesTests
{
    [TestClass()]
    public class AddressTypeRepositoryTest : RepositoryTestsBase<AddressType>
    {

        public override System.Linq.Expressions.Expression<Func<AddressType, bool>> FilterExpression
        {
            get { return a => a.TypeId == TestConstants.Instance.ADDRESS_TYPE_ID; }
        }

        public override System.Linq.Expressions.Expression<Func<AddressType, Guid>> OrderByExpression
        {
            get { return a => a.TypeId; }
        }
        
        [TestMethod]
        public void FindAddressTypeByName_Invoke_Test()
        {
            //Arrange 
            IMainModuleUnitOfWork context = GetUnitOfWork();
            ITraceManager traceManager = this.GetTraceManager();
            IAddressTypeRepository repository = new AddressTypeRepository(context, traceManager);

            string name = "Address Type Name";
            AddressTypeNameSpecification spec = new AddressTypeNameSpecification(name);

            //Act
            IEnumerable<AddressType> address = repository.GetBySpec(spec);

            //Assert
            Assert.IsNotNull(address);
            Assert.AreEqual(address.Count(), 1);
        }
    }
}
